
package com.shop.cloud.live.common.constant;

import java.util.Objects;

/**
 * 直播间状态 0.未开始 1.直播中 2.已结束 3.暂停中 -1.违规下架
 * @author
 */
public enum LiveRoomStatusType {

    /**
     * 违规下架
     */
    OFFLINE("-1"),

    /**
     * 未开始
     */
    NO_START("0"),

    /**
     * 直播中
     */
    LIVING("1"),

    /**
     * 已结束
     */
    FINISHED("2"),

    /**
     * 暂停中
     */
    STOP("3"),
    ;


    private final String num;

    public String value() {
        return num;
    }

    LiveRoomStatusType(String num){
        this.num = num;
    }

    public static LiveRoomStatusType instance(String value) {
        LiveRoomStatusType[] enums = values();
        for (LiveRoomStatusType statusEnum : enums) {
            if (statusEnum.value().equals(value)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static Boolean isNeedFinish(String value) {
        return Objects.equals(value, LiveRoomStatusType.STOP.value()) || Objects.equals(value, LiveRoomStatusType.LIVING.value()) || Objects.equals(value, LiveRoomStatusType.NO_START.value());
    }

    public static Boolean isNeedOpen(String value) {
        return Objects.equals(value, LiveRoomStatusType.STOP.value()) || Objects.equals(value, LiveRoomStatusType.NO_START.value());
    }
}
